DECRYPT

This program decrypts a file called hidden.txt using 1 to 1 substitution and puts the results in decrypted.txt. It requires a sample file from which to learn character frequencies, which must be called sample.txt. All of these files must be located in the directory from which the program is run.

By default the program calculates the frequency with which single characters appear in the sample file and simply substitutes them for the corresponding most frequent characters in the encrypted file. Ties are resolved randomly. You can also pass a commandline argument like so:

java Decrypt 2

or

java Decrypt 3

to have it use the frequencies of character combinations of size 2 or 3 respectively. Values >3 will not work.